class Singleton1{
    /*核-一个接收实例的静态成员*/
    private static people:Singleton1;
    private name:string;

    /*核心-私有构造函数*/
    private constructor(name:string) {
        this.name = name;
    }

    /*核心-获取实例*/
    public static getInstance():Singleton1{
        if(Singleton1.people == null){
            Singleton1.people = new Singleton1("懒汉式单例模式");
        }
        return Singleton1.people;
    }

    public say():void{
        console.log(`${this.name}`);
    }
}

/*测试代码*/
let people = Singleton1.getInstance();
people.say(); //懒汉式单例模式
